/*
  路由模块
*/
import Vue from "vue";
import VueRouter from "vue-router";
// 引入路由组件文件夹下的组件

import Login from "../pages/Login/Login";

// 自己的
import Home from "../pages/Home/Home.vue";
import { toUnicode } from "punycode";

// 路由组件懒加载
const TaskList = () => import("../pages/TaskList/TaskList.vue");
const TaskDetail = () => import("../pages/TaskDetail/TaskDetail.vue");
const Mine = () => import ("../pages/Mine/Mine.vue");
const Address = () => import ("../pages/Address/Address.vue")
const Message = () => import("../pages/Message/Message.vue");
const MessageDetail = () => import('../pages/MessageDetail/MessageDetail.vue');
const FormTable = () => import('../pages/FormTable/FormTable.vue');
const Todo = () => import ('../pages/Todo/Todo.vue');
const Dialog = () => import('../pages/Dialog/Dialog.vue');

// 全局注册Vue-router组件
Vue.use(VueRouter);

// 路由拦截


// 配置路由表并导出
export default new VueRouter({
  //  去掉地址中的哈希#
  // mode: "history",
  routes: [
    {
      path: "/",
      redirect: "/home",
      meta: { index: 0 }
    },
    {
      path: "/home",
      component: Home,
      meta: { index: 0 },
      // 此时的Msite等都是返回路由组件的函数，只有请求对应的路由路径时(第一次)才会执行此函数并加载路由组件
      // 标识此路由是否显示FooterGuide
      meta: {
        showFooter: true,
        index: 0
      }
    },
    {
      path: "/taskList",
      name: "taskList",
      component: TaskList,
      meta: {
        keepAlive: true, // 需要被缓存
        index: 1
      }
    },
    {
      path: "/details",
      component: TaskDetail,
      meta: { index: 2 }
    },
    {
      path: "/Login",
      component: Login,
      meta: {index: -1, disCheck: true}
    },
    {
      path: '/mine', 
      component: Mine,
      meta: {
        showFooter: true,
        index: 0
      }
    },
    {
      path: '/address', 
      component: Address,
      meta: {
        showFooter: true,
        index: 0
      }
    },
    {
      path: '/message',
      component: Message,
      meta: {
        index: 1
      }
    },
    {
      path: '/messageDetail',
      component: MessageDetail,
      meta: {
        index: 2
      }
    },
    {
      path: '/formTable',
      component: FormTable,
      meta: {
        index: 1
      }
    },
    {
      path: '/todo',
      component: Todo,
      meta: {
        index: 1
      }
    },
    {
      path: '/dialog',
      component: Dialog,
      meta: {index: -1, disCheck: true}
    }
    // {
    //   path: "/shop",
    //   component: Shop,
    //   children: [
    //     {
    //       path: "/shop/goods",
    //       component: ShopGoods
    //     },
    //     {
    //       path: "/shop/ratings",
    //       component: ShopRatings
    //     },
    //     {
    //       path: "/shop/info",
    //       component: ShopInfo
    //     },
    //     {
    //       path: "",
    //       redirect: "/shop/goods"
    //     }
    //   ]
    // }
  ]
});
